﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="DeliverGoodsManagement_PrintDeliverBillNew" Codebehind="PrintDeliverBillNew.aspx.cs" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>无标题页</title>
    <style type="text/css">
        *
        {
            padding: 0;
            margin: 0;
        }
        body
        {
            width: 80%;
            margin: 0 auto;
            font-size: 14px;
        }
        .page1
        {
            text-align: left;
        }
        table
        {
            width: 100%;
            border-collapse: collapse;
            margin: 10px 0;
        }
        th
        {
            text-align: left;
            padding: 3px;
            width: 75px;
        }
        td
        {
            text-align: left;
            padding: 3px;
            border-bottom: 1px solid #ccc;
        }
        h1
        {
            margin: 10px 0 10px;
            text-align: center;
        }
        h4
        {
            text-align: left;
            margin-bottom: 20px;
        }
        h6
        {
            font-size: 12px;
            font-weight: 100;
        }
        .messges
        {
            margin: 20px 0;
        }
        .messges th
        {
            border: solid 1px #ccc;
            padding: 5px;
            height: 50px;
            width: 65px;
        }
        .messges td
        {
            border: solid 1px #ccc;
            padding: 5px;
            height: 50px;
        }
        .tb td
        {
            border: solid 1px #ccc;
            height: 30px;
        }
        .footer td
        {
            border: 0;
            text-align: left;
        }
        
    </style>
    <style type="text/css" media="print">    
        .Noprint
        {   
            display:none;
        }    
        .PageNext
        {
            page-break-after: always;
        }    
    </style>   
    <!-- 插入打印控件 -->
    <%--<object id="jatoolsPrinter" classid="CLSID:B43D3361-D975-4BE2-87FE-057188254255"
        codebase="jatoolsPrinter_f.cab#version=2,1,0,3">
    </object>
--%>

    <script type="text/javascript">
    
    
    //初始化页面


function Init()
{   

    var url=window.location.href;
    var result = url.split('=');
    if(result.length>0)
    {
        DeliverGoodsManagement_PrintDeliverBillNew.GetData(result[1],Init_CallBack);  
        //doPrint();
    }
    
    
}

function Init_CallBack(response)
{
     if (response.value != null)
       {                   
        
        var ds = response.value;
        if(ds != null && typeof(ds) == "object" && ds.Tables != null)
        {    
            if(ds.Tables[0]!=null && ds.Tables[1]!=null)
            {
                for(var i=0; i<ds.Tables[0].Rows.length; i++)
                {
                    var orderId = ds.Tables[0].Rows[i].ORDER_ID;
                    var receiver = ds.Tables[0].Rows[i].ORDER_GETER;
                    var orderSource = ds.Tables[0].Rows[i].OF_NAME;
                    var totalQuantity = ds.Tables[0].Rows[i].ORDER_QTY;
                    var tranerName = ds.Tables[0].Rows[i].TRANER_NAME;
                    //发票
                    var isFAPIAO=ds.Tables[0].Rows[i].ORDER_NINV;
                    if(isFAPIAO=="0")
                    {
                       isFAPIAO="不需要";
                    }
                    else
                    {
                      isFAPIAO="需要";
                    }
                    //订购时间
                    var orderCreateDate=ds.Tables[0].Rows[i].ORDER_CREATEDATE;
                     dateObj = new Date(orderCreateDate)
                    orderCreateDate=dateObj.toLocaleDateString(); 
                    //备注信息
                    var note=ds.Tables[0].Rows[i].ORDER_NOTE;
                    
                    var ORDER_INVTITLE=ds.Tables[0].Rows[i].ORDER_INVTITLE
                    
                    var phone = ds.Tables[0].Rows[i].ORDER_GETERPHONE1;
                    var mobile = ds.Tables[0].Rows[i].ORDER_GETERPHONE2;
                    var userCode = ds.Tables[0].Rows[i].ORDER_CUSTOMERCODE;
                    var needToPay = ds.Tables[0].Rows[i].NeedToPay;
                    var tranCode = ds.Tables[0].Rows[i].ORDER_TRANBILLCODE;
                    var postCode = ds.Tables[0].Rows[i].ORDER_GETPOSTCODE;
                    var tranCost = ds.Tables[0].Rows[i].ORDER_TRANCOST;
                    var detailsPrice = ds.Tables[0].Rows[i].DetailsPrice;
                    var clearAmt = ds.Tables[0].Rows[i].ORDER_CLEARAMT;
                    var address=ds.Tables[0].Rows[i].ORDER_GETADDRESS;
                    var province=ds.Tables[0].Rows[i].PRONAME;
                    var city=ds.Tables[0].Rows[i].CITYNAME;
                    var area=ds.Tables[0].Rows[i].AREANAME;
                    var tempAddress = province;
                    if(city!="" && city!="直辖市" && city!="省直辖行政单位" && city!="市辖区")
                    {
                        tempAddress = tempAddress + city;
                    }  
                    if(area!="" && area!=" 其他")
                    {
                        tempAddress = tempAddress + area;
                    }
                    tempAddress = tempAddress + address;
                    
                    if(needToPay<0)
                    {
                        needToPay=0.00;
                    }
                    
                    var points = 0;
                    for(var m=0;m<ds.Tables[2].Rows.length;m++)
                    {
                        if(orderId == ds.Tables[2].Rows[m].od_id)
                        {
                            points = ds.Tables[2].Rows[m].points;
                            break;
                        }
                    }
                    
                    var intPoint = String(points).split(".");
                    points=intPoint[0];
                            
                    var temp = 0;
                    var tempValue = 0;
                    for(var j = 0;j<ds.Tables[1].Rows.length;j++)
                    {
                        if(orderId==ds.Tables[1].Rows[j].od_id && temp == 0)
                        {
                            var productId = ds.Tables[1].Rows[j].OD_CMDCODE;
                            var productName = ds.Tables[1].Rows[j].SPMC;
                            var color = ds.Tables[1].Rows[j].COLOR;
                            var size = ds.Tables[1].Rows[j].SIZE;
                            var quantity = ds.Tables[1].Rows[j].OD_QTY;
                            var note = ds.Tables[1].Rows[j].OD_NOTE;
                            var detailPrice = ds.Tables[1].Rows[j].OD_APRICE;
                            var detailAmount = ds.Tables[1].Rows[j].OD_AAMT;
                            var detailDiscount = ds.Tables[1].Rows[j].OD_DISC;
                            if(note=="" || note==null)
                            {
                                note = "&nbsp";
                            }
                            
                            CreateOrderTable(tempAddress,"start",orderId,receiver,orderSource,totalQuantity,tranerName,productName,productId,color,size,quantity,note,phone,mobile,userCode,needToPay,tranCode,postCode,tranCost,detailsPrice,clearAmt,points,detailPrice,detailAmount,detailDiscount,j,isFAPIAO,orderCreateDate,note,ORDER_INVTITLE);
                            temp++;
                            tempValue = 1;
                            
                            if(j+1==ds.Tables[1].Rows.length)
                            {
                                CreateOrderTable(tempAddress,"end",orderId,receiver,orderSource,totalQuantity,tranerName,productName,productId,color,size,quantity,note,phone,mobile,userCode,needToPay,tranCode,postCode,tranCost,detailsPrice,clearAmt,points,detailPrice,detailAmount,detailDiscount,j,isFAPIAO,orderCreateDate,note,ORDER_INVTITLE);
                            }
                            
                            continue;
                        }
                        else if(orderId==ds.Tables[1].Rows[j].od_id && temp > 0)
                        {
                            var productId = ds.Tables[1].Rows[j].OD_CMDCODE;
                            var productName = ds.Tables[1].Rows[j].SPMC;
                            var color = ds.Tables[1].Rows[j].COLOR;
                            var size = ds.Tables[1].Rows[j].SIZE;
                            var quantity = ds.Tables[1].Rows[j].OD_QTY;
                            var note = ds.Tables[1].Rows[j].OD_NOTE;
                            var detailPrice = ds.Tables[1].Rows[j].OD_APRICE;
                            var detailAmount = ds.Tables[1].Rows[j].OD_AAMT;
                            var detailDiscount = ds.Tables[1].Rows[j].OD_DISC;
                            if(note==""|| note==null)
                            {
                                note = "&nbsp";
                            }
                            
                            CreateOrderTable(tempAddress,"middle","&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;",productName,productId,color,size,quantity,note,phone,mobile,userCode,needToPay,tranCode,postCode,tranCost,detailsPrice,clearAmt,points,detailPrice,detailAmount,detailDiscount,j,isFAPIAO,orderCreateDate,note,ORDER_INVTITLE);
                            temp++;
                            tempValue = 1;
                            
                            if(j+1==ds.Tables[1].Rows.length)
                            {
                                CreateOrderTable(tempAddress,"end",orderId,receiver,orderSource,totalQuantity,tranerName,productName,productId,color,size,quantity,note,phone,mobile,userCode,needToPay,tranCode,postCode,tranCost,detailsPrice,clearAmt,points,detailPrice,detailAmount,detailDiscount,j,isFAPIAO,orderCreateDate,note,ORDER_INVTITLE);
                            }
                            
                            continue;
                        }
                        if(tempValue==1)
                        {
                            CreateOrderTable(tempAddress,"end","&nbsp;",receiver,"&nbsp;","&nbsp;","&nbsp;","","","","","","","","","",needToPay,"","",tranCost,"",clearAmt,"","","","","","","","","");
                            break;
                        }
                    }
                }
                DelectDiv();
            }
          }
       }                
    return;
}
    
function CreateOrderTable(address,temp,orderId,receiver,orderSource,totalQuantity,tranerName,productName,productId,color,size,quantity,note,phone,mobile,userCode,needToPay,tranCode,postCode,tranCost,detailsPrice,clearAmt,points,detailPrice,detailAmount,detailDiscount,count,isFAPIAO,orderCreateDate,note1,ORDER_INVTITLE)
{
    var mainDiv = document.getElementById("page1"); 
    count=count+1; 
    if(mainDiv!=null)
    {
        if(temp=="start")
        {
            
            var tableHtml = "<h1>f-club发货单</h1><br />";
         
            
            tableHtml+="<table class='tb'>";
            tableHtml+="<tr>";
            tableHtml+="<td>订单号：</td><td>"+orderId+"</td>";
            tableHtml+="<td>发货人姓名：</td><td>_____________</td>";
            tableHtml+="<td>发货单号：</td><td>_______________</td>";
            tableHtml+="<td>送货地址：</td><td>"+address+"</td>";
            tableHtml+="</tr>";
            tableHtml+="<tr>";
            tableHtml+="<td>手机：</td><td>"+mobile+"</td>";
            tableHtml+="<td>固定电话：</td><td>"+phone+"</td>";
            tableHtml+="<td>是否需要发票：</td><td>"+isFAPIAO+"</td>";
            tableHtml+="<td>发票抬头：</td><td>"+ORDER_INVTITLE+"</td>";
            tableHtml+="</tr>";
            tableHtml+="<tr>";
            tableHtml+="<td>送货时间：</td><td>____________</td>";
            tableHtml+="<td>邮编：</td><td>"+postCode+"</td>";
            tableHtml+="<td>送货方式：</td><td>"+tranerName+"</td>";
            tableHtml+="<td>支付方式：</td><td>____________</td>";
            tableHtml+="</tr>";
            tableHtml+="<tr>";
            tableHtml+="<td>邮箱地址：</td><td>____________</td>";
            tableHtml+="<td>订单状态：</td><td>____________</td>";
            tableHtml+="<td>订购日期：</td><td>"+unescape(orderCreateDate)+"</td>";
            tableHtml+="<td>备注信息：</td><td>"+note1+"</td>";
            tableHtml+="</tr>";           
            tableHtml+="</table>";
            
            
            
            
            tableHtml += "<table class='tb'>";
            tableHtml += "<tr class='z1'><td class='bk_left' width=9%>序号</td>";
            tableHtml += "<td class='bk_middle' width=9%>货位号</td>";
            tableHtml += "<td class='bk_middle' width=9%>商品编号</td>";
            tableHtml += "<td class='bk_middle' width=9%>商品名称</td>";

            tableHtml += "<td class='bk_middle' width=9%>商品尺码</td>";
            tableHtml += "<td class='bk_middle' width=9%>数量</td>";
            tableHtml += "<td class='bk_middle' width=9%>单价</td>";

            tableHtml += "<td class='bk_middle' width=9%>金额</td>";
            tableHtml += "<td class='bk_middle' width=9%>签收情况</td></tr>";
            tableHtml += "<tr class='z2'><td class='bk_left1'>" + count + "</td>";
            tableHtml += "<td class='bk_middle1'>000</td>";
            tableHtml += "<td class='bk_middle1'>" + productId + "</td>";
            tableHtml += "<td class='bk_middle1'>" + productName + "</td>";

            tableHtml += "<td class='bk_middle1'>" + size + "</td>";
            tableHtml += "<td class='bk_middle1'>" + quantity + "</td>";
            tableHtml += "<td class='bk_middle1'>" + detailPrice + "</td>";

            tableHtml += "<td class='bk_middle1'>" + detailAmount + "</td>";
            tableHtml += "<td class='bk_middle1'>&nbsp;</td></tr>";
            
            mainDiv.innerHTML += tableHtml;
            
            return;
        }
        else if(temp=="middle")
        {
            var tableHtml = "";
            tableHtml += "<tr class='z2'><td class='bk_left1'>" +  count+ "</td>";
            tableHtml += "<td class='bk_middle1'>000</td>";
            tableHtml += "<td class='bk_middle1'>" + productId + "</td>";
            tableHtml += "<td class='bk_middle1'>" + productName + "</td>";

            tableHtml += "<td class='bk_middle1'>" + size + "</td>";
            tableHtml += "<td class='bk_middle1'>" + quantity + "</td>";
            tableHtml += "<td class='bk_middle1'>" + detailPrice + "</td>";

            tableHtml += "<td class='bk_middle1'>" + detailAmount + "</td>";
            tableHtml += "<td class='bk_middle1'>&nbsp;</td></tr>";
            var strHtml = mainDiv.innerHTML;
            //alert(strHtml);
            var str = strHtml.substring(0,strHtml.length-14);
            mainDiv.innerHTML = str+tableHtml;
            
            return;
        }
        else if(temp=="end")
        {
            var tableHtml = "";
            var allPrice=clearAmt+ needToPay;
            tableHtml+="<table class='messges'><tr><th>配送费用：</th><td>"+tranCost+"</td><th>总计：</th><td>"+allPrice+"</td><th>已收款：</th><td>"+clearAmt+"</td><th>应收款：</th><td>"+needToPay+"</td></tr></table>";   
            tableHtml+="<h4>如果您已经收到我们配送的商品进行检验，确认上述商品信息、付款信息和收货人信息无误，所收到商品包装完好，商品没有划痕、破损等表面质量问题，请在本发货单客户签收处签字确认，您的签字即视为您已确认并同意上述内容。如您委托他人验收上述商品，您委托的收货人的签字即视为您的签字确认。</h4>";
            tableHtml+="<h4>售中热线：_____________________</h4>";
            
            tableHtml += "<h4>送货人：___________________________             " + "&nbsp;&nbsp;&nbsp;&nbsp;收货时间：______年___月____日___时___分&nbsp;&nbsp;&nbsp;客户签名：_____________________________</h4>";
            tableHtml += "<div class='PageNext'></div>";
            
            var strHtml = mainDiv.innerHTML;
            //alert(strHtml);
            var str = strHtml.substring(0,strHtml.length);
            //alert(str);
            mainDiv.innerHTML = str+tableHtml;
            
            return;
        }
        
        
    }
}
        function DelectDiv()
        {
             var mainDiv = document.getElementById("page1");  
             var strHtml = mainDiv.innerHTML;
             var str = strHtml.substring(0,strHtml.length-28);
             mainDiv.innerHTML = str;
        }
        function printa(){    
            var form = document.getElementById("order1form");    
            var hid = document.getElementById("print");    
            hid.value=1;    
            form.action = "/searchOrder1.do";    
            form.submit();    
        }    
            
        function go(url){    
            window.location.href=url;    
        }    
        function printsetup(){    
        // 打印页面设置    
        wb.execwb(8,1);    
        }    
        function printpreview(){    
        // 打印页面预览    
                    
        wb.execwb(7,1);    
                      
                    
        }    
            
        function printit()    
        {    
        if (confirm('确定打印吗？')) {    
            var cen = document.getElementById("center");    
            cen.innerHTML = '';    
            wb.execwb(6,6)    
            }    
        }   
    
    function doPrint()
    {  
   
    if(typeof(jatoolsPrinter.page_div_prefix)=='undefined'){
        alert("请按页顶上的黄色提示下载ActiveX控件.如果没有提示请按以下步骤设置ie.\n 工具-> internet 选项->安全->自定义级别,设置 ‘下载未签名的 ActiveX ’为'启用'状态")
        return ;
    }
	//打印文档对象
    var myreport ={ 
                    print_settings:{
                                  // 如果想使用默认打印机,不需要设置


                                  // printer: '联想激打',

                                 // 指定纸张的高宽以毫米为单位z,本设置实际是指定为a4大小
                                pageWidth : 2100,
                                pageHeight :2970,

                               // 指定打打印方向为横向, 1/2 = 纵向/横向
                               orientation : 1 }, 
    				documents: document,    // 打印页面(div)们在本文档中
    				marginIgnored:true,
    				copyrights  :    '杰创软件拥有版权 www.jatools.com'         // 版权声明必须
    			  };
    			  
    // 调用打印方法
    //if(how == '打印预览...')
    	jatoolsPrinter.printPreview(myreport );   // 打印预览
                 
   	//else if(how == '打印...')
   		//jatoolsPrinter.print(myreport ,true);   // 打印前弹出打印设置对话框
                
   //	else
   		//jatoolsPrinter.print(myreport ,false);       // 不弹出对话框打印
   		
}
    </script>

</head>
<body onload="Init()">
    <form id="form1" runat="server">
    <object id="WebBrowser" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height="0" width="0" VIEWASTEXT> 
    </object> 
        <%--<img src="../Include/Images/HS_logo.gif" alt="" />--%>
    <input   onclick="document.all.WebBrowser.ExecWB(8,1)" class="Noprint" type="button"   value="页面设置"   name="Button4"/>           
    <input   onclick="document.all.WebBrowser.ExecWB(7,1)" class="Noprint" type="button"   value="打印预览" name="Button"/>      
    <input   onclick="document.all.WebBrowser.ExecWB(6,1)" class="Noprint" type="button"   value="打印"   name="Button"/> 
    <div id="page1">
    </div>
    </form>
</body>
</html>
